<?php

class ${a_pluralize_cap(class_name)}Controller extends BaseController {

    public function index() {
        $${a_pluralize(class_name)} = ${a_singularize_cap(class_name)}::paginate(10);
        return View::make('${a_pluralize(class_name)}.index', array('${a_pluralize(class_name)}' => $${a_pluralize(class_name)}));
    }

    public function add() {
        return View::make('${a_pluralize(class_name)}.add');
    }

    public function create() {
        ${a_singularize_cap(class_name)}::save(Input::all());
    }

    public function read($id) {
        $${a_singularize(class_name)} = ${a_singularize_cap(class_name)}::find($id);
        return View::make('${a_pluralize(class_name)}.read', array('${a_singularize(class_name)}' => $${a_singularize(class_name)}));
    }

    public function edit($id) {
        $${a_singularize(class_name)} = ${a_singularize_cap(class_name)}::find($id);
        return View::make('${a_pluralize(class_name)}.update', array('${a_singularize(class_name)}' => $${a_singularize(class_name)}));
    }

    public function update() {
        $${a_singularize(class_name)} = ${a_singularize_cap(class_name)}::find(Input::get('id'));
        $${a_singularize(class_name)}->name = Input::get('name');
        $${a_singularize(class_name)}->save();
        return Redirect::to('${a_pluralize(class_name)}');
    }

    public function delete($id) {
        $${a_singularize(class_name)} = ${a_singularize_cap(class_name)}::find($id);
        $${a_singularize(class_name)}->delete();
        return Redirect::to('${a_pluralize(class_name)}');
    }

}
